<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page contentType="text/html;charset=utf-8" language="java"%>
<%
    String baseP = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + "/";
%>

<!doctype html>
<html>
<head>

    <title>违法查询</title>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link type="text/css" href="<c:url value='/resource/css/wechat-common.css'/>" rel="stylesheet"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta http-equiv="cleartype" content="on" />
    <link rel="shortcut icon" href="/nocontent" />

    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="width=device-width,user-scalable=no" />
    <meta name="viewport" id="viewport" />

    <script type="text/javascript"
            src="<c:url value='/resource/js/jquery-2.0.min.js'/>"></script>
    <script src="<c:url value='/resource/js/common.js'/>" type="text/javascript"></script>
    <script type="text/javascript">
        function check(num){
            var pushId = $("#pushId").val().trim();
            var pushType = $("#pushType").val().trim();
            var rep=/[A-Z]{1}[A-Z_0-9]{5}$/;
            var rep_num = /[a-z_A-Z_0-9]{6}/;
            var dabhFormat = /[0-9]{18}/;
            var fnFormat = /[a-z_A-Z_0-9]{6}/;
            var jdchphm = $("#jdchphm").val().trim();
            var fdj = $("#fdj").val().trim();
            var jtglywdxsfzhm = $("#jtglywdxsfzhm").val().trim();
            var dabh = $("#dabh").val().trim();
            var firnull = "车牌号不能为空";
            var secnull = "发动机后六位不能为空";
            var firformet = "车牌号格式不正确";
            var secformet = "请输入发动机后六位";
            if(1 == num){
                firnull = "驾驶证编号不能为空";
                secnull = "档案编号不能为空";
                firformet = "驾驶证编号格式不正确";
                secformet = "请输入档案编号后6位";
                if(jtglywdxsfzhm == null || jtglywdxsfzhm == ""){
                    toast(firnull, 1500);
                    return false;
                }else if(dabh == null || dabh == ""){
                    toast(secnull, 1500);
                    return false;
                }else if(!dabhFormat.test(jtglywdxsfzhm)){
                    toast(firformet, 1500);
                    return false;
                }else if(!fnFormat.test(dabh)){
                    toast(secformet, 1500);
                    return false;
                }else{
                    $.ajax({
                        url: "<c:url value='/api/query/license/points'/>",
                        type: "post",
                        data: {"jtglywdxsfzhm": jtglywdxsfzhm,"dabh":dabh,"pushId":pushId,"pushType":pushType},
                        timeout: 6000,
                        beforeSend: function () {
                            loading();
                        },
                        success: function (data) {
                            $("#btn_query_two").attr("disabled","disabled");
                            $("#btn_query_two").css("background-color","#DDDDDD");
                            $("#resulttwo").html(data.msg);
                            finish();
                        },
                        error: function () {
                            finish("查询失败")
                        }
                    });
                }

            }else{
                if(jdchphm == null || jdchphm == ""){
                    toast(firnull, 1500);
                    return false;
                }else if(fdj == null || fdj == ""){
                    toast(secnull, 1500);
                    return false;
                }else if(!rep.test(jdchphm)){
                    toast(firformet, 1500);
                    return false;
                }else if(!rep_num.test(fdj)){
                    toast(secformet, 1500);
                    return false;
                }else{
                    var jdccllxbm = $("#jdccllxbm").val().trim();
                    $.ajax({
                        url: "<c:url value='/api/query/vehicle/illegal'/>",
                        type: "post",
                        data: {"jdccllxbm": jdccllxbm,"fdj":fdj,"jdchphm":jdchphm,"pushId":pushId,"pushType":pushType},
                        timeout: 6000,
                        beforeSend: function () {
                            loading();
                        },
                        success: function (data) {
                            $("#btn_query").attr("disabled","disabled");
                            $("#btn_query").css("background-color","#DDDDDD");
                            $("#result").html(data.msg);
                            finish();
                        },
                        error: function () {
                            finish("查询失败")
                        }
                    });
                }
            }
        }

        function hiden(){
            $(".toast").hide();
        }

        function changetab(num){
            if(1 == num){
                $("#wzcx_car").css("display","block");
                $("#wzcx_drive").css("display","none");
                $("#tapbtn_1").css("background","#BBD6F2");
                $("#tapbtn_2").css("background","#FFFFFF");
            }
            if(2 == num){
                $("#wzcx_car").css("display","none");
                $("#wzcx_drive").css("display","block");
                $("#tapbtn_1").css("background","#FFFFFF");
                $("#tapbtn_2").css("background","#BBD6F2");
            }
        }
    </script>
    <style type="text/css">
        .main {
            font-size: 1.6em;
            margin: 8px;
        }
        .main .form {
            height: 50px;
            line-height: 50px;
            border: 1px solid #dddddd;
            width: 100%;
            border-top: 0;
        }
        #wzcx_car {
            border-top: 1px solid #dddddd;
            margin: 0 8px;
        }
        #wzcx_drive {
            border-top: 1px solid #dddddd;
            margin: 0 8px;
        }

        .main .boder-top {
            border-top: 1px solid #dddddd
        }
        .border_top_radius {
            border-top-left-radius: 3px;
            border-top-right-radius: 3px;
        }
        .border_bottom_radius {
            border-bottom-left-radius: 3px;
            border-bottom-right-radius: 3px;
        }
        .main .form .label {
            height: 50px;
            line-height: 50px;
            color: #157dfb;
            text-indent: 0.8em;
            float: left;
            width: 95px;
        }
        .main .form .element {
            height: 50px;
            line-height: 50px;
            margin-left: 100px;
            display: block;
        }
        .main .form .element input {
            color: #666;
            font-family: "微软雅黑", serif;
            text-indent: 0.3em;
            border: 0;
            width: 98%;
            font-size: 1.0em;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }

        .main .btn:active {
            background-color: #3300ff;
            cursor: hand;
        }
        #result {
            min-height: 6em;
            margin: 10px 10px;
            line-height: 2;
            height: 2em;
            color: #837D7D;
        }
        #resulttwo {
            min-height: 6em;
            margin: 10px 10px;
            line-height: 2;
            height: 2em;
            color: #837D7D;
        }
        .main .uptop {
            margin-top: -1.6em;
        }
        .main .form input {
            border: none;
            font-size: 1.1em;
            color: #a28d8d;
        }

        .main .searchbom {
            border: 1px solid rgb(182, 176, 176);
            border-bottom: none;
            border-bottom-left-radius: 0;
            border-bottom-right-radius: 0;
            margin-bottom: 0;
        }
        .main .other {
            border-radius: 0;
            margin-top: 0;
            margin-bottom: 0;

        }
        .main .searchtop {
            border-top-right-radius: 0;
            border-top-left-radius: 0;
            margin-top: 0;
            border-top: none;
        }
        #pol_station, #pol_office {
            display: none;
        }

        #btn_query {
            text-decoration: none;
        }

        #btn_query_two {
            text-decoration: none;
        }

        .tabbtn {
            width: 100%;
            margin: 0 0 15px 0 ;
        }

        #tapbtn_1, #tapbtn_2 {
            height: 60px;
            width: 49.8%;
            border-bottom: 1px solid #dddddd;
            border-left: none;
            border-right: none;
            border-top: none;
        }
        #tapbtn_1 {
            margin-right: -2.5px;
            background: #BBD6F2;
            color:#fff;
        }
        #tapbtn_2 {
            margin-left: -2.5px;
            background: #FFFFFF;
            color:#666;
        }
        .tabbtn span {
            text-indent: 0.8em;
            margin: 5px 7px 5px 7px;
            font-family: "黑体";
            font-size: 1.1em;
            color:#666;
        }
        .myselect{
            -webkit-appearance: none;
            border: 0;
            background: 0 0;
            padding-right: 14px;
            width: 90%;
            font-size: 1.0em;
            color: #666;
            font-family: "微软雅黑", serif;
            text-indent: 0.3em;
        }
    </style>
</head>

<body>
<div class="main" style="margin: 0;">
    <div class="tabbtn" id="tabbtn">
        <button id="tapbtn_1" onclick="changetab(1)">
            <span>机动车违法查询</span>
        </button>
        <button id="tapbtn_2" onclick="changetab(2)">
            <span>驾驶证违法查询</span>
        </button>
    </div>
    <div id="wzcx_car">

        <div class="form">
            <span class="label">车辆类型</span>
            <span class="element">
                <select id="jdccllxbm" name="jdccllxbm" class="myselect no-border">
                    <c:forEach var="carType" items="${carTypelist}" varStatus="vs">
                        <option value="${carType.code}">${carType.name}</option>
                    </c:forEach>
                </select>
            </span>
        </div>
        <div class="form">
            <span class="label">车牌号</span><span style="padding: 0;float:left;">辽</span>
            <span class="element"><input id="jdchphm" name="jdchphm" class="no-border" type="text" minLength="6" maxLength="6" placeholder="请输入六位车牌号" onkeyup="this.value=this.value.toUpperCase()" onfocus="hiden()"/></span>
        </div>
        <div class="form"  style="border-bottom-radius:3px;">
            <span class="label">发动机</span>
            <span class="element"><input id="fdj" name="fdj" class="no-border" type="text" maxLength="6" onfocus="hiden()" placeholder="请输入您发动机号后六位"/></span>
        </div>
        <div>
            <input type="hidden" name="pushId" id="pushId" value="${pushId}" />
            <input type="hidden" name="pushType" id="pushType" value="${pushType}" />
            <button href="#" onclick="check(0)" id="btn_query" class="btn simple no-border">查 询</button>
        </div>
        <div id="toast" class="toast"></div>
        <div id="result"></div>
    </div>
    <div id="wzcx_drive" style="display: none;">
        <div class="form">
            <span class="label">驾驶证编号</span>
            <span class="element"><input id="jtglywdxsfzhm" name="jtglywdxsfzhm" class="no-border" type="text" maxLength="18" onfocus="hiden()" placeholder="请输入驾驶证编号"/></span>
        </div>
        <div class="form">
            <span class="label">档案编号</span>
            <span class="element"><input id="dabh" name="dabh" class="no-border" type="text" maxLength="12" onfocus="hiden()" placeholder="请输入档案编号"/></span>
        </div>
        <div>
            <input type="hidden" name="pushId" id="pushId" value="${pushId}" />
            <input type="hidden" name="pushType" id="pushType" value="${pushType}" />
            <button href="#" onclick="check(1)" id="btn_query_two" class="btn simple no-border">查 询</button>
        </div>
        <div id="toast" class="toast"></div>
        <div id="resulttwo"></div>
    </div>
</div>
</body>
</html>
